package com.ktgj.pay.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.pay.domain.PayBusiness;
import com.ktgj.pay.service.IPayBusinessService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 业务线支付Controller
 * 
 * @author ruoyi
 * @date 2022-01-08
 */
@RestController
@RequestMapping("/business")
public class PayBusinessController extends BaseController
{
    @Autowired
    private IPayBusinessService payBusinessService;

    /**
     * 查询业务线支付列表
     */
    @PreAuthorize(hasPermi = "pay:business:list")
    @GetMapping("/list")
    public TableDataInfo list(PayBusiness payBusiness)
    {
        startPage();
        List<PayBusiness> list = payBusinessService.selectPayBusinessList(payBusiness);
        return getDataTable(list);
    }

    /**
     * 导出业务线支付列表
     */
    @PreAuthorize(hasPermi = "pay:business:export")
    @Log(title = "业务线支付", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PayBusiness payBusiness) throws IOException
    {
        List<PayBusiness> list = payBusinessService.selectPayBusinessList(payBusiness);
        ExcelUtil<PayBusiness> util = new ExcelUtil<PayBusiness>(PayBusiness.class);
        util.exportExcel(response, list, "业务线支付数据");
    }

    /**
     * 获取业务线支付详细信息
     */
    @PreAuthorize(hasPermi = "pay:business:query")
    @GetMapping(value = "/{businessId}")
    public AjaxResult getInfo(@PathVariable("businessId") Long businessId)
    {
        return AjaxResult.success(payBusinessService.selectPayBusinessById(businessId));
    }

    /**
     * 新增业务线支付
     */
    @PreAuthorize(hasPermi = "pay:business:add")
    @Log(title = "业务线支付", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PayBusiness payBusiness)
    {
        return toAjax(payBusinessService.insertPayBusiness(payBusiness));
    }

    /**
     * 修改业务线支付
     */
    @PreAuthorize(hasPermi = "pay:business:edit")
    @Log(title = "业务线支付", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PayBusiness payBusiness)
    {
        return toAjax(payBusinessService.updatePayBusiness(payBusiness));
    }

    /**
     * 删除业务线支付
     */
    @PreAuthorize(hasPermi = "pay:business:remove")
    @Log(title = "业务线支付", businessType = BusinessType.DELETE)
	@DeleteMapping("/{businessIds}")
    public AjaxResult remove(@PathVariable Long[] businessIds)
    {
        return toAjax(payBusinessService.deletePayBusinessByIds(businessIds));
    }
}
